%% exercise 4 in erlang programming
%% author:gaoyunpeng
-module(chapter4).
-export([start/0,print/1,stop/0,loop/0]).
%% exercise 4-1

start() ->
	register(echo,spawn(chapter4,loop,[])).
print(Term) ->
	echo ! {self(),Term}.
stop() ->
	echo ! stop.
loop() ->
	receive
		{_Pid,Msg} ->
			io:format("~w~n",[Msg]),
			loop();
		stop ->
			true
	end.
